package zhishu.iceyyy.com.kd_khd.fragment;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import zhishu.iceyyy.com.kd_khd.R;
import zhishu.iceyyy.com.kd_khd.er_fragment.Menu_FragmentAdapter;


/**
 * 我的
 */
public class SY_Fragment extends Fragment {
    View view;

    Unbinder unbinder;


    @BindView(R.id.tabs)
    android.support.design.widget.TabLayout tabs;
    @BindView(R.id.pager)
    ViewPager pager;
    @BindView(R.id.activity_main)
    LinearLayout activityMain;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if (view == null) {
            view = View.inflate(getActivity(), R.layout.fragment_sy, null);
            ButterKnife.bind(this, view);
            dd();
        }
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null) {
            parent.removeView(view);
        }

        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    public void dd() {
        pager.setAdapter(new Menu_FragmentAdapter(getChildFragmentManager(), getActivity()));
        tabs.setTabMode(TabLayout.MODE_SCROLLABLE);
        tabs.setupWithViewPager(pager);// 将viewpager和mIndicator关联起来,必须在viewpager设置完adapter后才能调用
    }

}
